
#pragma once

#include <list>
#include <vector>
#include "Particle.h"
#include "Vector2.h"
#include "MagnetConstVariable.h"
#include "HCI\ParticleSystem.h"

using namespace std;

typedef struct Magnet{

	Vector2 pos;
	Vector2 mm;
	
}Magnet;


typedef struct tempdata{

		Vector2 pos;
		Vector2 origin;
		RGB rgb;
		RGB delrgb;
		HSL hsl;
		int num;

		tempdata():rgb(0,0,0), num(0), delrgb(0,0,0){};

}tempdata;



class MagnetSystem{


private:

	list<Magnet *> MagnetList;
	int numMagnet;

	list<Magnet*>::iterator it;


	int maxx;
	int maxy;
	tempdata **tdata;

public:

	MagnetSystem(){
		numMagnet = 0;

	};//constructor();

	~MagnetSystem() {
		printf("Destructor MagnetSystem\n");
		DeleteAllMagnet();
	}

	void AddMagnet(Magnet *mg);
	void DeleteAllMagnet();
	Vector2 ComputeMfield(Vector2 pos);
	void ComputeMm(Particle *ptc);
	Vector2 ComputeMm(Vector2 pos);
	Vector2 ComputeForce(Particle *ptc);
	void Mov(Vector2 force, Particle *ptc);
	


	void MagnetSimulation(std::vector<Particle>* ptc_list, int width, int height);
	
	void Make_tdata(vector<Particle> *ptc_list, int width, int height);
	void del_tdata();
	void lgtParticle(vector<Particle> *ptc_list);
	void calrefrac();

	void MagnetSystem::transfer(vector<Particle> *ptc_list);
	void MagnetSystem::MovRGB();
	RGB MagnetSystem::divRGB(Vector2 Origin, Vector2 Pos, RGB rgb);
	void MagnetSystem::adjRGB(Vector2 pos, RGB rgb);


	__forceinline list<Magnet*>::iterator MagnetList_Begin() { return it = MagnetList.begin(); };
	__forceinline list<Magnet*>::iterator MagnetList_End() { return MagnetList.end(); };

};//class MagnetSystem